-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CS224W - Bag of Tricks for Node Classification with GNN - GAT Normalization #9840
Open
liuvince
wants to merge
16
commits into
pyg-team:master
Choose a base branch
from
mattjhayes3:gat_normalization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
liuvince
requested review from
a team,
wsad1,
EdisonLeeeee and
rusty1s
as code owners
December 10, 2024 20:54
liuvince
changed the title
Gat normalization
CS224W - Bag of Tricks for Node Classification with GNN - GAT Normalization
Dec 10, 2024
…sage passing yet and add num_nodes as parameters
liuvince
force-pushed
the
gat_normalization
branch
from
December 11, 2024 19:59
0ff800b
to
76cab5d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9840 +/- ##
==========================================
+ Coverage 85.29% 86.36% +1.06%
==========================================
Files 478 490 +12
Lines 31918 32386 +468
==========================================
+ Hits 27225 27969 +744
+ Misses 4693 4417 -276 ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
normalize
parameter toGATConv
andGATv2Conv
.Part of #9831 for our final project for the Stanford CS224W course, this allows "GAT with Symmetric Normalized Adjacency Matrix" as described in “Bag of Tricks for Node Classification with Graph Neural Networks”.
Details
gat_norm
inspired fromgcn_norm
, whenedge_index
is aSparseTensor
,is_torch_sparse_tensor
or dense torchTensor
.gat_norm
is called after computing thealpha
coefficients and return the updated values ofedge_index
andalpha
. The outputs ofgat_norm
are passed as inputs ofself.propagate
.GATConv
andGATv2Conv
.add_self_loops
parameter. We remove self loops from the initial graph before calling togat_norm
and add self loops with normalization ingat_norm
as described in the paper. We tried to use the tools already provided in the library such astorch_sparse.fill_diag
,to_edge_index
,add_remaining_self_loops
,add_self_loops
andto_torch_csr_tensor
.is_torch_sparse_tensor(edge_index) == True
, we have an issue formatting back the indexedge_index
and the corresponding values inatt_mat
to the appropriate format. Our workaround consists of sorting lexicographically the values ofatt_mat
, so it matches the index ofedge_index
for thepropagate
andupdate
subsequent steps.isinstance(edge_index, SparseTensor)
and in the case we have multiple heads, e.g.num_heads > 1
, we need to perform the operationnum_heads
times. We don't userepeat_interleave
directly as we encounter the following error:"repeat_interleave_cpu" not implemented for 'Float'
, but the current implementation should follow the same behavior.Benchmarks
I have the following metrics with one T4 GPU, so it performs better for CiteSeer and PubMed dataset with a computation time cost.
with the following run commands: